/**
 * 面试题 17.16 按摩师
 */
public class Exerciser1 {
    public int massage(int[] nums) {
        int n = nums.length;
        if(n == 0) {
            return 0;
        }
        //选
        int[] f = new int[n];
        //不选
        int[] g = new int[n];
        //初始化
        f[0] = nums[0];
        g[0] = 0;
        for(int i = 1;i < n;i++) {
            f[i] = g[i - 1] + nums[i];
            g[i] = Math.max(f[i - 1],g[i - 1]);
        }
        return Math.max(f[n - 1],g[n - 1]);
    }
}
